#!/usr/bin/env perl
# ------------------------------------------------------------------------
#   File Name: scs2hex.pl
#      Author: Zhao Yanbai
#              Tue Feb 14 15:13:02 2012
# Description: Shell Code String ==> Hex
# ------------------------------------------------------------------------
use strict;

my $infile = @ARGV[0];
my $outfile= @ARGV[1];

unless($infile) {
    print "Error: No Input and Output File\n";
    exit;
}
unless($outfile) {
    print "Error: No Output File\n";
    exit;
}

open S, "<", $infile;
open D, ">", $outfile;

while(<S>) {
    my $v = $_;
    chop($v);
    my @a = split(/\\x/, $v);
    $v = "";
    foreach (@a) {
        $v .= $_;
    }
    print D pack("H*", $v);
}

close D;
close S;
